import { BroadCastCall } from "../broadCast/BroadCastCall";
import { MessageBlock } from "../../../../Framework/MQ/MessageBlock";
import { SBagCapacityChangeMsg } from "../../../../Message/Game/SBagCapacityChangeMsg";
import { EPlayerItemPosType } from "../../../../Message/Public/EPlayerItemPosType";
import { ECategory } from "../../../../Message/Public/ECategory";
import { NetDispatcher } from "../../../mvc/core/NetDispatcher";
import { ServerCommand } from "../../mvc/ServerCommand";
import { Cache } from "../../cache/Cache";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
//class BagCapacityChangeCommand
    
    export  class BagCapacityChangeCommand extends BroadCastCall
    {
        constructor(arg1: Object)
        {
            super(arg1);
            return;
        }

        public /* override */ call(arg1: MessageBlock): void
        {
            var loc3=0;
            var loc4=0;
            var loc5=0;
            var loc6=0;
            super.call(arg1);
            var loc1=arg1.messageBase as SBagCapacityChangeMsg;
            var loc2=loc1.posType;
            if (loc2 != EPlayerItemPosType._EPlayerItemPosTypeBag) 
            {
                if (loc2 != EPlayerItemPosType._EPlayerItemPosTypeWarehouse) 
                {
                    if (loc2 != EPlayerItemPosType._EPlayerItemPosTypePet) 
                    {
                        if (loc2 != EPlayerItemPosType._EPlayerItemPosTypePetWarehouse) 
                        {
                            if (loc2 > EPlayerItemPosType._EPlayerItemPosTypePetEquipBase) 
                            {
                                if ((loc5 = loc1.category) == ECategory._ECategoryPetLifeStyle) 
                                {
                                    loc6 = loc2 - EPlayerItemPosType._EPlayerItemPosTypePetEquipBase;
                                    _cache.petMing.mingCapacituDict[loc6] = loc1.newCapacity;
                                }
                                NetDispatcher.dispatchCmd(ServerCommand.PetMingCapacityCommand, _cache.petMing.mingCapacituDict);
                            }
                        }
                        else 
                        {
                            loc4 = loc1.newCapacity;
                            Cache.instance.petWareHouse.capacity = loc4;
                            NetDispatcher.dispatchCmd(ServerCommand.PetWareHouseCapacityChange, loc4);
                        }
                    }
                    else 
                    {
                        loc3 = loc1.newCapacity;
                        Cache.instance.pet.capacity = loc3;
                        Dispatcher.dispatchEvent(new DataEvent(EventName.PetBagCapacityChange));
                    }
                }
                else 
                {
                    NetDispatcher.dispatchCmd(ServerCommand.WareHouseCapacityChange, arg1.messageBase);
                }
            }
            else 
            {
                NetDispatcher.dispatchCmd(ServerCommand.BackPackCapacityChange, arg1.messageBase);
            }
            return;
        }
    }
